const url = require("url");
const fs = require("fs");

module.exports = function( p ){
  return (req,res,next)=>{
    const pathname = url.parse(req.url).pathname;
    fs.readFile(p + pathname, (err, data)=>{
      if(err){
        res.send("404");
      }else{
        res.write(data);
        res.end();
      }
    })
    // next();
  }
}